<%@page import="bean.B01boardDTO"%>
<%@page import="bean.B01boardVO" %>
<%@page import="java.util.ArrayList" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>List</title>
<link rel="stylesheet" href="/Web/02CSS/B01board.css">
<script src = '/Web/03JavaScript/B01board.js'></script>
</head>
<body>
<jsp:useBean id="vo" class="bean.B01boardVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>
<%
	B01boardDTO dto = new B01boardDTO();
	dto.setVo(vo);
	ArrayList<B01boardVO> al = dto.select();	
%>

<h1>자유게시판 리스트</h1>
<hr>
	<form name = 'hiddenFrm' method='post'>
		 	<input type='hidden' name="nowPage">
		 	<input type='hidden' name='find'>
		 	<input type='hidden' name='b_number'>
	</form>
	<div>
		<form action="index.jsp?inc=/04JSP/01Board/list.jsp" name ='board_list_frm' method = 'post'>
			<input type="text" name = 'find' value ="<%=vo.getFind()%>"/>
			<input type="submit" value='검색'>
		</form>
	</div>
	<p/>
	<div id = 'board_list_title'>
		<div class='board_list_b_number'>글번호</div>
		<div class='board_list_b_title'>제목</div>
		<div class='board_list_m_id'>글쓴이</div>
		<div class='board_list_b_date'>작성일</div>
		<div class='board_list_b_image'>파일</div>
	</div>
<%for(int a=0; a<al.size(); a++){ 
	B01boardVO v = al.get(a);
%>
 <div class="board_list_items">
		<div class='board_list_b_number'><%=v.getB_number()%></div>
		<div class='board_list_b_title'> <!-- 실제 클릭되는 값   -->
			<a href = '#' onclick="goView(<%=dto.getNowPage()%>,<%=v.getB_number()%>)">
			<% 	if(v.getB_title().length()>20){
				String title = v.getB_title().substring(0, 20); %>
		    	<%=title%>...
			<%} else {%>
				<%=v.getB_title()%>
			<%}%>
			</a>
		</div>
		<div class='board_list_m_id'><%=v.getM_id()%></div>
		<div class='board_list_b_date'>
			<% 	String date = (String)v.getB_date();
				if(date.length()>10){
				String date1 = date.substring(0, 10); %>
		    	<%=date1%>
			<%} else {%>
				<%=v.getB_date()%>
			<%}%>
		</div>
		<div class='board_list_b_modifyDate'><%=v.getB_modifyDate()%></div>
		<div class='board_list_b_image'>		
		<% if(v.getB_image()!= null){%>	
			 <% if(v.getB_image().length()>15){
				String image = v.getB_image().substring(0, 15); %>
		    	<%=image%>..
			<%}else{%>
				<%=v.getB_image()%> 
			<%}%>	
		<%}else{%>
			파일없음
		<%}%>
		</div>
	</div>	
<%}%>	
<div id = 'list_page' align="center">
		<% if(dto.getNowPage()==1){%>
		[처음으로]
		<%}else{%><a href='#' onclick='goPage(1)'>[처음으로]  </a>
		<%}%>
		
	<% if(dto.getNowBlock()==1){%>
		[이전으로]
		<%}else{%><a href="#" onclick='goPage(<%=dto.getStartPage()-1 %>)'>[이전으로]</a>
		<%} %>	
	<%	
	int i=0;
	for(i = dto.getStartPage(); i<=dto.getEndPage(); i++){%>
	<a href= "#" onclick = "goPage(<%= i %>)"><%= i %></a>
	<%} %>
	<% if(dto.getNowBlock()==dto.getTotBlock()){%>
		[다음으로]
		<%}else{%><a href= '#' onclick = "goPage(<%=i %>)">  [다음으로]</a>
		<%} %>
	
	<% if(dto.getNowPage()==dto.getTotPage()){%>
		[맨끝으로]
		<%}else{%><a href= "#" onclick = "goPage(<%=dto.getTotPage() %>)">  [맨끝으로]</a>
		<%} %>	
	
</div>
<hr>
	<input type="button" value="새로고침" style="margin-left: 50px;"/>
	<input type="button" value="새 글쓰기" id="btnInput" style="margin-left: 650px;"/>
</body>
<script>listInit();</script>
</html>